<?php

error_reporting(E_ALL);

/**
 * cn.solor.dig - class.JSDecodedAnalyzer.php
 *
 * $Id: class.JSDecodedAnalyzer.php,v 1.2 2008-01-14 15:32:04 rainx Exp $
 *
 * This file is part of cn.solor.dig.
 *
 * Automatic generated with ArgoUML 0.22 on 17.12.2006, 10:07:15
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * include BasicAnalyzer
 *
 * @author firstname and lastname of author, <author@example.org>
 */
//require_once('class.BasicAnalyzer.php');

/**
 * include CommonAnalyzer
 *
 * @author firstname and lastname of author, <author@example.org>
 */
///require_once('class.CommonAnalyzer.php');

///for jscript decode
/// wrapper 
function jsDecoder(&$body)
{
   global $transformed, $pick_encoding, $digits, $entities, $rawData ;
   require_once ('jsdecoder.php');
   return  ScriptDecoder($body, 936); //asume only chinese site use jscript.encoding
}

/* user defined includes */
// section 127-0-0-1--5e4d4b42:10f8dcad467:-8000:0000000000000819-includes begin
// section 127-0-0-1--5e4d4b42:10f8dcad467:-8000:0000000000000819-includes end

/* user defined constants */
// section 127-0-0-1--5e4d4b42:10f8dcad467:-8000:0000000000000819-constants begin
// section 127-0-0-1--5e4d4b42:10f8dcad467:-8000:0000000000000819-constants end

/**
 * Short description of class JSDecodedAnalyzer
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class JSDecodedAnalyzer
     extends CommonAnalyzer
        implements Analyzer
{
    // --- ATTRIBUTES ---
    public $features = array('content' => '/jscript.encode/i');
    // --- OPERATIONS ---

    function analyze($content, $url)
    {
        /*
           FIXME
            yep , We fetch the page twice, I don't konw why ,but it seems there are some
            encoding issues while go through some pages convent from gbk to utf-8
        */
        //$req = new HTTP_Request($url);
        //$req->sendRequest();
        //$body = $req->getResponseBody();
        $body = $this->getPage($url);
        return parent::analyze(jsDecoder($body), $url);
    }

} /* end of class JSDecodedAnalyzer */

?>
